package com.example.controller;

import java.util.List;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.example.bean.UserDO;
import com.example.service.UserService;

/**
 * <p>
 *  前端控制器
 * </p>
 *
 * @author lfh
 * @since 2022-11-19
 */
@RestController
@RequestMapping("/user")
public class UserController {

    @Autowired
    private UserService userService;

    /**
     * 根据ID查询用户信息
     * @param id
     * @return
     */
    @GetMapping("/getOneUser/{id}")
    public UserDO getOneUser(@PathVariable("id") Integer id){
        return userService.getById(id);
    }

    /**
     * 获取所有的用户信息
     * @return
     */
    @GetMapping("/getAllUser")
    public List<UserDO> getAllUser(){
        return userService.list();
    }

}
